package com.tucy.logistics.modules.system.role.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tucy.logistics.common.dto.system.QueryRoleDto;
import com.tucy.logistics.common.entity.user.SystemRole;
import com.tucy.logistics.common.result.Result;
import com.tucy.logistics.modules.system.role.service.SystemRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * author: tcy
 * createDate: 2023/9/14
 * description: 角色服务
 */
@Api(tags = "角色服务")
@RestController
@RequestMapping("/role")
public class SystemRoleController {

    @Autowired
    SystemRoleService systemRoleService;

    @ApiOperation(value = "查询角色")
    @PostMapping("/pageRole")
    public Result<Page<SystemRole>> queryRole(@RequestBody QueryRoleDto role) {
        return Result.success(systemRoleService.queryRole(role));
    }

    @ApiOperation(value = "增改角色")
    @PostMapping("/saveUpdateRole")
    public Result<Boolean> saveUpdateRole(@RequestBody SystemRole role) {
        return Result.success(systemRoleService.saveUpdateRole(role));
    }

    @ApiOperation(value = "删除角色")
    @PostMapping("/deleteRole")
    public Result<Boolean> deleteRole(@RequestBody List<Long> ids) {
        return Result.success(systemRoleService.deleteRole(ids));
    }

}
